<template>
  <div class="AssetCount-wrap">
    <div>
      <el-tooltip
        placement="bottom"
        :disabled="item.weaknessCount <= 0 ? true : false"
      >
        <div v-if="item.weaknessCount" slot="content" class="content">
          <p v-for="(child, index) in item.weaknessSortByLevel" :key="index">
            <span>{{ child.key }}</span>
            <span>{{ child.docCount }}</span>
          </p>
        </div>
        <div>
          <span class="name">存在弱点</span>
          <span class="count">{{ item.weaknessCount }}</span>
        </div>
      </el-tooltip>
    </div>
    <div>
      <el-tooltip
        placement="bottom"
        :disabled="dataSourceNum <= 0 ? true : false"
      >
        <div v-if="dataSource" slot="content" class="content">
          <p v-for="(tag, index) in dataSource.split(',')" :key="index">
            {{ tag }}
          </p>
        </div>
        <div>
          <span class="name">暴露源</span>
          <span class="count">{{ dataSourceNum }}</span>
        </div>
      </el-tooltip>
    </div>
  </div>
</template>
<script lang="ts" setup>
import { defineProps, computed } from 'vue';
const props = defineProps({
  item: {
    type: Object,
    default: () => {
      return {};
    },
  },
});
const dataSource = computed(() => {
  if (props.item) {
    return props.item.dataSource || props.item.sourceName;
  }
  return null;
});
const dataSourceNum = computed(() => {
  if (props.item.dataSource) {
    // 使用字符串的 split 方法并返回数组的长度
    return props.item.dataSource.split(',').length;
  }
  return 0;
});
</script>

<style lang="scss" scoped>
.AssetCount-wrap {
  display: flex;
  align-items: center;

  > div {
    &:first-child {
      margin-right: 10px;
    }

    .name {
      font-family: PingFangSC-Regular;
      font-size: 12px;
      line-height: 20px;
      letter-spacing: 0px;
      // color: rgba(255, 255, 255, 0.8);
    }

    .count {
      font-family: PingFangSC-Medium;
      font-size: 16px;
      line-height: 22px;
      letter-spacing: 0px;
      color: #0289f7;
    }
  }
}
</style>
